package sk.upjs.ariadne.editor.maplayers;

import javax.swing.JPanel;
import javax.swing.JToggleButton;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class WallLayerControl extends JPanel {

	/**
	 * Layer controlled by this control panel.
	 */
	private WallLayer layer;
	
	JToggleButton btnEditMode;

	/**
	 * Create the panel.
	 */
	public WallLayerControl(WallLayer layer) {
		this.layer = layer;

		btnEditMode = new JToggleButton("Insertion");
		btnEditMode.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (btnEditMode.isSelected())
					WallLayerControl.this.layer
							.setEditMode(WallLayer.EditMode.WALL_INSERTION);
				else
					WallLayerControl.this.layer
							.setEditMode(WallLayer.EditMode.SELECTION);
			}
		});
		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(
				Alignment.LEADING).addGroup(
				groupLayout.createSequentialGroup().addComponent(btnEditMode)
						.addContainerGap(391, Short.MAX_VALUE)));
		groupLayout.setVerticalGroup(groupLayout.createParallelGroup(
				Alignment.LEADING).addGroup(
				groupLayout.createSequentialGroup().addComponent(btnEditMode)
						.addContainerGap(277, Short.MAX_VALUE)));
		setLayout(groupLayout);
		btnEditMode.setSelected(layer.getEditMode().equals(
				WallLayer.EditMode.WALL_INSERTION));
	}
}
